package com.tcs.test.zk.discovery.provider;

import java.io.IOException;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;
import com.tcs.test.zk.ZkTest1;
import com.tcs.test.zk.base.BaseZookeeper;
import com.tcs.test.zk.discovery.ServiceInfo;

public class ProviderA extends BaseZookeeper {
	
	private static final Logger logger = LoggerFactory.getLogger(ZkTest1.class);
	
	@Test
	public void test() {
		try {
			new Provider(
			        new ServiceInfo(
			                "service-A",
			                "192.168.1.111",
			                Lists.newArrayList("m1", "m2")
			        ),
			        cf,
			        "192.168.1.111"
			).start();
			new Provider(
			        new ServiceInfo(
			                "service-A",
			                "192.168.1.113",
			                Lists.newArrayList("m1", "m2")
			        ),
			        cf,
			        "192.168.1.111"
			).start();
			new Provider(
			        new ServiceInfo(
			                "service-B",
			                "192.168.1.112",
			                Lists.newArrayList("m3", "m4")
			        ),
			        cf,
			        "192.168.1.112"
			).start();
		} catch (Exception e) {
			logger.error("" , e);
		} finally {
			try {
				System.in.read();
			} catch (IOException e) {
				logger.error("" , e);
			}
		}
	}
}